home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94a.txt / 000039_icon-group-sender _Fri Jan 28 22:30:28 1994.msg < prev    next >
Internet Message Format  |  1994-08-19  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Sun, 6 Feb 1994 20:13:59 MST
  2. Date: 28 Jan 94 22:30:28 GMT
  3. From: cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!newncar!csn!server!usenet@ucbvax.Berkeley.EDU  (Cheyenne Wills)
  4. Organization: Storage Technology Corp.
  5. Subject: Re: Table look up questions?
  6. Message-Id: <CKD2Iu.HI9@stortek.com>
  7. References: <2ibt39$ojg@uop.cs.uop.edu>
  8. Sender: icon-group-request@cs.arizona.edu
  9. To: icon-group@cs.arizona.edu
  10. Status: R
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12.  
  13. In <2ibt39$ojg@uop.cs.uop.edu>, wclark@uop.edu (William Clark) writes:
  14.  ........
  15. >
  16. >   Example:  User inputs:  H W <enter>
  17. >         Output: Hello World
  18. >
  19. >   Where "H W" is a key in the table and "Hello World" is the other
  20. >   half.
  21.  .......
  22. >
  23. >   William R. Clark
  24. >   University of the Pacific
  25. >   wclark@thor.cs.uop.edu
  26. >
  27.  
  28.    Icon has builting table support, basically dynamic arrays that
  29. are "indexed" by a string (associtive arrays).  So for your example:
  30.  
  31. procedure main()
  32.    wordtbl := table()
  33.    wordtbl["H W"] := "Hello World"
  34.    wordtbl["G D"] := "Good Day"
  35.    wordtbl["G B"] := "Good By"
  36.  
  37.    write("User input:")
  38.    line := read()
  39.    line := trim(line)
  40.    newline := wordtbl[line]
  41.    write("Output: ",newline)
  42. end
  43.  
  44. Of course things like making checking to see if the data was in
  45. the table can be done by simply testing to see if "wordtbl[line]"
  46. is &null.  Also the issue of upper/lower case and multiple blanks
  47. hasn't been addressed.
  48.  
  49.  
  50. +--------------------------------------+---------------------------------+
  51. | +-----+                   | Cheyenne Wills          |
  52. | |    |      "From here on up it is  | Storage Technology Corporation  |
  53. | |  +--+--+     downhill all the way" | 2270 South 88th St.             |
  54. | |  |    |  |                   | Louisville, Co. 80028-4232     |
  55. | +--+--+  |   These are not the       |                 |
  56. |    |       |   opinions or views of    | Cheyenne_Wills@stortek.com     |
  57. |    +-----+   Storage Technology      | cheyenne@witsend.stortek.com     |
  58. +--------------------------------------+---------------------------------+
  59.